אשף התצוגה המקדימה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
אשף התצוגה המקדימה נועד לאפשר לכם לשלב תצוגות מקדימות במהירות, בקלות ובצורה מהימנה באתר שלכם. ניתן להטמיע צופה בספרים, לקשר ל-Book Search או אפילו להוסיף לאתר חלון קופץ עם תצוגה מקדימה - כל מה שצריך לעשות הוא ליצור את הקוד ולהדביק אותו בדף. אפשר גם להתאים אישית את הקוד הזה באמצעות כמה פונקציות JavaScript פשוטות.
אשף התצוגה המקדימה הוא ספריית נוחות פשוטה שפיתחנו מעל ממשקי ה-API של קישורים דינמיים וצפייה מוטמעת. אם אתם מפתחים מתקדמים שמעוניינים בשילוב מותאם אישית, כדאי להשתמש ישירות בממשקי ה-API הבסיסיים.
יצירת הקוד של התצוגה המקדימה
דוגמאות לתצוגות מקדימות שנוצרו
הדוגמאות הבאות נוצרו באמצעות אשף התצוגה המקדימה.
התאמה אישית של הקוד
בנוסף לשימוש באשף שלמעלה, ניתן להפעיל ישירות כמה פונקציות "עזרה" פשוטות של JavaScript. לשם כך, עליך לטעון תחילה את ספריית אשף התצוגה המקדימה. דרך אחת לעשות זאת היא להוסיף את התג הבא לקטע <head>
בדף:
<script type="text/javascript" src="https://books.google.com/books/previewlib.js"></script>
אחרי שטענתם את ספריית התצוגה המקדימה, תוכלו להפעיל כל אחת מהפונקציות הבאות מתוך התגים <script>
ב-<body>
של המסמך. לדוגמה, אם רוצים להוסיף את הלחצן "תצוגה מקדימה של Google", צריך להוסיף את הקוד כדי לעשות זאת ברכיב <script>
במיקום הרצוי ללחצן בתוך הדף.
GBS_setLanguage
GBS_setLanguage(languageCode)
שינוי השפה של הלחצנים או הטקסט שנוספו אחרי הקריאה לפונקציה הזו. התוכן הזה כולל את השפה של הלחצן 'תצוגה מקדימה של Google', את שפת הממשק של התצוגה המקדימה המוטמעת וכו'.
פרמטרים:
string languageCode
– קוד השפה הרצוי לפי RFC 3066 (ברירת המחדל היא 'en' לאנגלית). קודי השפות הנתמכים כרגע כוללים hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it, ja, ko, lv, lt, no, pl, pt-BR, pt-rus, th.
GBS_setViewerOptions
GBS_setViewerOptions(optionObj)
פרמטרים:
Object optionsObj
- קבוצה של צמדי מפתח-ערך שמועברים אל DefaultViewer API של ה-API להטמעת נתוני צפייה. בדרך כלל משתמשים בשיטה הזו כדי לבצע התאמות אישיות מתקדמות.
GBS_setCobrandName
GBS_setCobrandName(cobrandName)
הפונקציה הזו מיועדת לשימוש על ידי מוציאים לאור בתוכנית השותפים. היא מגדירה את השימוש באתר חיפוש במיתוג משותף להזנה של קישורים לתצוגה מקדימה ל-Book Search. קריאה לפונקציה הזו לפני הוספת לחצן מבטיחה שהמשתמשים יראו את הלוגו של השותף מעל התצוגה המקדימה של חיפוש הספרים.
פרמטרים:
string cobrandName
- השם של המותג המשותף שצריך להוסיף לכל כתובת URL של חיפוש בספרים. בדרך כלל זה מה שמופיע אחרי /p/
בכתובות URL קיימות של תצוגה מקדימה של 'חיפוש במיתוג משותף'.
לדוגמה, אם מגדירים את הערך sup
, המשתמש יועבר לקישורים כמו
https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover
במקום לברירת המחדל
https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover
GBS_insertEmbeddedViewer
GBS_insertEmbeddedViewer(identifier, opt_width, opt_height)
הוספת תצוגה מקדימה של ספר מוטמע בכל מקום שבו מופעלת הפונקציה הזו. אם התצוגה המקדימה לא זמינה, לא מוצג אף צופה.
פרמטרים:
Number opt_width
– הרוחב הרצוי של הצופה, בפיקסלים.
Number opt_height
– הגובה הרצוי של הצופה, בפיקסלים.
GBS_insertPreviewButtonPopup(identifiers)
אם התצוגה המקדימה של הספר זמינה, הפונקציה הזו כותבת לחצן 'תצוגה מקדימה של Google'. לחיצה על הלחצן הזה פותחת 'חלון תצוגה מקדימה צף' בחלק העליון של הדף. אם אין תצוגה מקדימה זמינה, הלחצן לא יוצג.
מפתחים מתוחכמים יותר עשויים להתעניין ב-Embedded Viewer API, שהפונקציה הזו משתמשת בו באופן פנימי.
פרמטרים:
string, Array identifier
– כתובת URL של תצוגה מקדימה או מזהה ספר, כמו מספר ISBN, OCLC או LCCN. למידע נוסף, כדאי לעיין בקטע פורמט הבקשות של קישורים דינמיים. אם אתם יודעים על כמה מזהים חלופיים של הספר, תוכלו להעביר מערך של המזהים האלה והלחצן יופיע אם יש תצוגה מקדימה זמינה לאחד מהם.
GBS_insertPreviewButtonLink(identifiers, opt_options)
אם התצוגה המקדימה של הספר זמינה, הפונקציה הזו כותבת לחצן 'תצוגה מקדימה של Google' שפשוט מקשר לדף תצוגה מקדימה של הספר. כברירת מחדל, הקטע הזה מקשר לתצוגה המקדימה ב-Google Books, אבל אפשר גם:
- מקשרים לכתובת אתר באתר שלך (שצריכה, בתורה, להכיל מציג מוטמע). כדי לעשות זאת, מעבירים אפשרות של
alternativeUrl
אופציונלית.
- מקשרים לגרסה במיתוג משותף של דף התצוגה המקדימה של הספר, אם בוצעה קריאה אל GBS_setCobrandName לפני הפונקציה הזו.
אם אין תצוגה מקדימה זמינה למשתמש, שום לחצן לא יוצג בדף.
פרמטרים:
string, Array identifier
– כתובת URL של תצוגה מקדימה או מזהה ספר, כמו מספר ISBN, OCLC או LCCN. למידע נוסף, כדאי לעיין בקטע פורמט הבקשות של קישורים דינמיים. אם אתם יודעים על כמה מזהים חלופיים של הספר, תוכלו להעביר מערך של המזהים האלה והלחצן יופיע אם יש תצוגה מקדימה זמינה לאחד מהם.
Object opt_options
– אופציונלי – מפה של ערך-שם שמשמשת להגדרת ההתנהגות של הלחצן. כרגע יש תמיכה באפשרות אחת: alternativeUrl
. לדוגמה, כדי שלחצן התצוגה המקדימה של Google יקשר לדף תצוגה מקדימה מותאם אישית באתר, יש להעביר את הארגומנט הבא כארגומנט שני אל GBS_insertPreviewButtonLink
:
{ 'alternativeUrl' : 'http://yoursite.com/your-preview-page' }
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2024-06-28 (שעון UTC).
[null,null,["עדכון אחרון: 2024-06-28 (שעון UTC)."],[],[],null,["# Preview Wizard\n\nThe Preview Wizard is designed to let you quickly, easily, and reliably integrate previews with your site. You can embed a book viewer, link to Book Search, or even add a preview \"popup\" window to your site---all you need to do is [generate the code](#generateCode) and paste it onto your page. You can also [customize this code](#customizeYourCode) using some simple JavaScript functions.\n\nThe Preview Wizard is a simple convenience library we built on top of our [Dynamic Links](/books/docs/dynamic-links) and [Embedded Viewer](/books/docs/viewer/developers_guide) APIs. If you're an advanced developer looking for customized integration, consider\nusing the underlying APIs directly.\n\nGenerate your preview code\n--------------------------\n\n#### Enter book identifiers\n\nTell us all the ISBNs or other identifiers you know of for this book. If we can find a preview associated with any of these numbers, we can make it available to your site's users:\n\n|--------------------------------------|---|\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n| ISBN OCLC number LCCN Book Search ID | |\n\n[Enter more identifiers...](about:invalid#zGoSafez)\n\n#### Choose how to show the book preview\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| If a preview is available for this book, what should the user see on your page? |---|------------------------------------------------------------------------| | | An embedded book viewer. Viewer size: pixels wide, pixels high | | | A button that opens a floating book viewer. | | | A button that links to the book's preview page on Book Search. | | | A button that goes to a custom preview page on your site. Preview URL: | If no preview can be found for the specified book(s), the preview or button will be automatically disabled and nothing will appear. | |\n\n#### Select your language\n\nChinese (Simplified) Chinese (Traditional) Dutch English French German Italian Japanese Portuguese (Brazilian) Russian Spanish\n\n#### Generate code for your web page\n\nExamples of generated previews\n------------------------------\n\nThe following examples were generated using the Preview Wizard.\n\n- [previewwizard-embed](/books/examples/previewwizard-embed): Embeds a book viewer on the page.\n- [previewwizard-popup](/books/examples/previewwizard-popup): Adds a button that can be clicked to open a floating preview over the page.\n- [previewwizard-linktogbs](/books/examples/previewwizard-linktogbs): Inserts a button that links to the preview on the Book Search site.\n- [previewwizard-customurl](/books/examples/previewwizard-customurl): Shows a button that goes to a specific URL.\n\nCustomize your code\n-------------------\n\nIn addition to using the wizard above, you can call some simple JavaScript \"helper\" functions directly. To do this, you should first load the Preview Wizard library. One way to do this is by adding the following tag to the `\u003chead\u003e` section of your page: \n\n```\n\u003cscript type=\"text/javascript\" src=\"https://books.google.com/books/previewlib.js\"\u003e\u003c/script\u003e\n```\n\nHaving loaded the preview library, you can then call any of the following functions from within `\u003cscript\u003e` tags inside your document's `\u003cbody\u003e`. For example, if you'd like to insert the \"Google Preview\" button, you'd put the code to do so in a `<script\u003e` element at the button's desired position within the page.\n\n### GBS_setLanguage\n\n```\nGBS_setLanguage(languageCode)\n```\n\nChanges the language of any buttons or text added after this function is called. This includes the language of the \"Google Preview\" button, the interface language of the embedded preview, and so on.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` languageCode ` - The desired RFC 3066 language code (default is 'en' for English). Currently supported language codes include hy, bg, ca, zh-CN, zh-TW, hr, cs, da, nl, en, fil, fi, fr, de, el, hi, hu, is, id, in, it, ja, ko, lv, lt, no, pl, pt-BR, pt-PT, ro, ru, sr, sk, sl, es, sv, th, tr, uk, and vi.\n\n### GBS_setViewerOptions\n\n```\nGBS_setViewerOptions(optionObj)\n```\n\n**Parameters:** *Object*` optionsObj ` - A set of key-value pairs passed to the Embedded Viewer API's [DefaultViewer constructor](/books/docs/viewer/reference#google.books.DefaultViewer). Typically, this is used for advanced customizations.\n\n### GBS_setCobrandName\n\n```\nGBS_setCobrandName(cobrandName)\n```\n\nIntended for use by publishers in the [Partner Program](https://books.google.com/partner), this function sets the [Co-Branded Search](https://books.google.com/support/partner/bin/answer.py?hl=en&answer=65113) site to be used when inserting any preview links to Book Search. Calling this function before inserting a button ensures that users see the partner's logo above the Book Search previews.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` cobrandName ` - The cobrand name to be added to any Book Search URLs. This is typically what comes after `/p/` in existing Co-Branded Search preview URLs.\n- For example, setting the value to `sup` will send the user to links like \n `https://books.google.com/books/p/sup?id=Q8ysL64pM54C&printsec=frontcover` \n rather than the default \n `https://books.google.com/books?id=Q8ysL64pM54C&printsec=frontcover`\n\n### GBS_insertEmbeddedViewer\n\n```\nGBS_insertEmbeddedViewer(identifier, opt_width, opt_height)\n```\n\nInserts an embedded book preview wherever this function is called. If the preview is unavailable, no viewer is shown.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat).\n\u003c!-- --\u003e\n\n*Number*` opt_width ` - The desired width of the viewer, in pixels.\n\u003c!-- --\u003e\n\n*Number*` opt_height ` - The desired height of the viewer, in pixels.\n\n### GBS_insertPreviewButtonPopup\n\n```\nGBS_insertPreviewButtonPopup(identifiers)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button. Clicking this button opens a \"floating preview window\" right on top of your page. If no preview is available, the button is not drawn.\n- More sophisticated developers may be interested in the [Embedded Viewer API](/books/docs/viewer/developers_guide), which this function uses internally.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\n### GBS_insertPreviewButtonLink\n\n```\nGBS_insertPreviewButtonLink(identifiers, opt_options)\n```\n\nIf the book preview is available, this function writes out a \"Google Preview\" button that simply links off to a preview page for the book. By default, this links to the preview on Google Books, but you can also:\n- link to a URL on your site (which should, in turn contain an embedded viewer). You can do this by passing an optional `alternativeUrl` option.\n- link to a Co-Branded version of the book preview page, if [GBS_setCobrandName](#GBS_setCobrandName) is called before this function.\nIf no preview is available to the user, no button is drawn onto the page.\n\n\u003c!-- --\u003e\n\n**Parameters:** *string, Array*` identifier ` - A preview URL or book identifier such as an ISBN, OCLC, or LCCN number. See [Dynamic Links request format](/books/docs/dynamic-links#requestFormat). If you know of several alternative identifiers for the book, you can pass an array of these identifiers, and the button will appear if a preview is available for any one of them.\n\u003c!-- --\u003e\n\n*Object*` opt_options ` - *optional* - A name-value map used to configure the behavior of the button. Currently one option is supported: `alternativeUrl`. For example, to have the Google Preview button link to a custom preview page on your site, simply pass the following as a second argument to `GBS_insertPreviewButtonLink`: \n` { 'alternativeUrl' : 'http://yoursite.com/your-preview-page' } `"]]